<template>
	<view class="content">
		<view class="login-bg">
			<view class="login-card">
				<view class="login-head">学生登入</view>
				<view class="login-input login-margin-b">
					<input v-model="loginForm.username" type="number" placeholder="用户名" />
				</view>
				<view class="login-input">
					<input v-model="loginForm.password" type="password" placeholder="请输入密码(6-15位)" />
				</view>
				<view class="login-function">
					<button class="login-register" type="default" @click="go_register">快速注册></button>
				</view>
			</view>
		</view>
		<view class="login-btn">
			<button class="landing" type="primary" @click="stulogin()">登陆</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
				loginForm: {
					username: "",
					password: "",
				},
			};
		},
		onLoad() {

		},
		methods: {
			stulogin() {
				uni.request({
					url: 'http://127.0.0.1:8443/api/stulogin',
					method: "POST",
					data: {
						stuAccount: this.loginForm.username,
						stuPass: this.loginForm.password
					},
					success: function(res) {
						console.log(res.data);
						if (res.data.code == 200) {
							console.log(res.data.code);
							uni.setStorageSync("stuid", res.data.data.id);
							uni.setStorageSync("stuname", res.data.data.stuName);
							uni.navigateBack({
								delta: 1
							})
						}
					}
				})
			},
			go_forget() {
				uni.navigateTo({
					url: '../forget/forget'
				})
			},
			go_register() {
				uni.navigateTo({
					url: '../register/register',
				})
			}

		}
	}
</script>

<style>
	.landing {
		height: 84upx;
		line-height: 84upx;
		border-radius: 44upx;
		font-size: 32upx;
		background: linear-gradient(left, #FF978D, #FFBB69);
	}

	.login-btn {
		padding: 10upx 20upx;
		margin-top: 350upx;
	}

	.login-function {
		overflow: auto;
		padding: 20upx 20upx 30upx 20upx;
	}

	.login-forget {
		float: left;
		font-size: 26upx;
		color: #999;
	}

	.login-register {
		color: #666;
		float: right;
		font-size: 26upx;

	}

	.login-input input {
		background: #F2F5F6;
		font-size: 28upx;
		padding: 10upx 25upx;
		height: 62upx;
		line-height: 62upx;
		border-radius: 8upx;
	}

	.login-margin-b {
		margin-bottom: 25upx;
	}

	.login-input {
		padding: 10upx 20upx;
	}

	.login-head {
		font-size: 34upx;
		text-align: center;
		padding: 25upx 10upx 55upx 10upx;
	}

	.login-card {
		background: #fff;
		border-radius: 12upx;
		padding: 10upx 25upx;
		box-shadow: 0 6upx 18upx rgba(0, 0, 0, 0.12);
		position: relative;
		margin-top: 120upx;
	}

	.login-bg {
		height: 260upx;
		padding: 25upx;
		background: linear-gradient(#FF978D, #FFBB69);
	}
</style>
